package yxy.cherry.battle.module.affix.skill;

import yxy.cherry.battle.Battle;
import yxy.cherry.battle.Fighter;
import yxy.cherry.battle.module.PropertyType;
import yxy.cherry.battle.module.affix.AffixContext;
import yxy.cherry.battle.module.affix.AffixContext.AffixTarget;
import yxy.cherry.battle.module.affix.AffixFactory.SkillTypeEnum;
import yxy.cherry.battle.module.affix.Skill;
import yxy.cherry.battle.module.affix.SkillType;
import yxy.cherry.data.bean.skill;

import java.util.ArrayList;

/**
 * 增伤靠数值(增伤靠属性)
 * */
@SkillType(Type = SkillTypeEnum.增伤靠数值)
public class Affix_16_增伤靠数值 extends Skill {

	private PropertyType get属性类型() {
		return PropertyType.forNumber(getParam(0));
	}
	private int get增伤比例() {
		return getParam(1);
	}

	public Affix_16_增伤靠数值(Fighter actor, skill skilldata, int probability, int[] params) {
		super(actor, skilldata, probability, params);
	}

	@Override
	public boolean exec(Fighter actor, Fighter target) {
		long 属性值 = actor.getProperty(get属性类型());

		AffixContext.AffixAction affixAction = getAffixAction();
		AffixTarget affixTarget = affixAction.getTarget(target);

		if(target.equals(affixAction.get针对目标())) {

			ArrayList<Long> 伤害流 = affixTarget.get伤害流();
			ArrayList<Long> 效果流 = affixTarget.get效果流();

			long addDamage = 属性值 * get增伤比例() / VALUE_比率分母;


			伤害流.add(addDamage);
			效果流.add(0L);
			Battle.battleLogger(6,"增伤靠数值：施法者：" + actor.getName() + "对象：" + affixTarget.get目标().getName()+"属性类型"+get属性类型()+"增伤比例"+get增伤比例() + "最终伤害：" + addDamage);
			affixTarget.set伤害流(伤害流);
			affixTarget.set效果流(效果流);
		}

		return true;
	}

}